package com.java2007.hotel.controller;

import com.java2007.hotel.constant.Constant;
import com.java2007.hotel.factory.BeanFactory;
import com.java2007.hotel.pojo.DetailOrder;
import com.java2007.hotel.service.DetailOrderService;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.sql.SQLException;
import java.util.List;

/**
 * 处理订单详情请求
 * @author csl
 * @version V1.0
 * @date 2021/01/23
 **/
@WebServlet("/hotel/DetailOrder")
public class DetailOrderServlet extends BaseServlet {
    private DetailOrderService detailOrderService = (DetailOrderService) BeanFactory.getBean(Constant.DETAIL_ORDER_SERVICE_IMPL);
    /**
     * 查询订单
     * @param req
     * @param resp
     * @return
     */
    public String detail(HttpServletRequest req, HttpServletResponse resp) {
        String number = req.getParameter("number");
        HttpSession session = req.getSession();
        List<DetailOrder> detailOrders = null;
        try {
            detailOrders = detailOrderService.selectDetailOrderByOrder(number);
        } catch (SQLException e) {
            e.printStackTrace();
            return "ss";
        }
        session.setAttribute("detailOrders",detailOrders);

        return "redirect:" + req.getContextPath() + "/hotel/backend/detail/order/orderDetail.jsp";
    }


}
